<%
    if (session.getAttribute("userid") == null) {
        session.invalidate();
        getServletContext().getRequestDispatcher("/MainController?q=index").forward(request, response);
    }
%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>AsportoOnline | La mia pagina</title>

        <script src="http://maps.google.com/maps?file=api&AMP;v=2.55&AMP;key=ABQIAAAA4sriqqpkT4rZot1cK9vguRTEe3oPwTvvxdMV9j-szy2Bac4x0hTS_bXwPwBy0LvCWWXgMNkzvr87gQ" type="text/javascript"></script>

        <script src="http://maps.google.com/maps/api/js?sensor=true" type="text/javascript"></script> 


        <script type="text/javascript">
            function geolocalizzami() {
                //                document.registra.action = "MainController?q=modify_user_action";
                //                document.registra.submit();
                var query = document.getElementById("via").value + ", " + document.getElementById("cap").value + " " + document.getElementById("citta").value;
                
                var coder = new GClientGeocoder();
                coder.getLatLng(query, salva_coord);
            };
            
            function salva_coord(punto){ 
                //alert("Latitudine: "+punto.lat()+" Longitudine: "+punto.lng());
                //document.getElementsByName("coordinate").value = "Latitudine: "+punto.lat()+" Longitudine: "+punto.lng();
                document.getElementById("latitudine").value = punto.lat();
                document.getElementById("longitudine").value = punto.lng();
                
                if(!isNaN(punto.lat()) && !isNaN(punto.lng())) {                
                    document.registra.action = "MainController?q=modify_user_action";
                    //alert("A" + document.getElementById("latitudine").value + " " + document.getElementById("longitudine").value);
                    document.registra.submit();
                }
            };
        </script>

        <style type="text/css">
            @import url("style.css");
        </style>
    </head>
    <body>
        <div class="meister">
            <div class="page">
                <div class="container">
                    <%@ include file="/WEB-INF/common/header.jsp"%>
                    <div class="navigation"> <a id="first" href="MainController?q=index">Home</a> > La mia pagina </div>      

                    <div class="uniform_background">
                        <div class="center">
                            <h1>Modifica i tuoi dati</h1>

                            <form class="smallform" name="registra" method="POST" action="javascript:geolocalizzami()">
                                <fieldset><legend><em>Dati anagrafici</em></legend>
                                    <label>Nome<br /><input name="nome" value="<%=request.getAttribute("nome").toString()%>" disabled="disabled"/></label><br />
                                    <label>Cognome<br /><input name="cognome" value="<%=request.getAttribute("cognome").toString()%>" disabled="disabled"/></label><br />
                                    <label>Data di nascita<br /><input name="datan" value="<%=request.getAttribute("datan").toString()%>" disabled="disabled"/></label><br />
                                    <label>Codice Fiscale<br /><input name="cf" value="<%=request.getAttribute("cf").toString()%>" disabled="disabled"/></label><br />
                                </fieldset>
                                <fieldset><legend><em>Informazioni di contatto</em></legend>
                                    <label class="editable">Via<br /><input id="via" name="via" value="<%=request.getAttribute("via").toString()%>"/></label><br />
                                    <label class="editable">CAP<br /><input id="cap" name="cap" value="<%=request.getAttribute("cap").toString()%>"/></label><br />
                                    <label class="editable">Citt&agrave;<br /><input id="citta" name="citta" value="<%=request.getAttribute("citta").toString()%>"/></label><br />
                                    <input id="latitudine" type="hidden" name="latitudine" value="vuoto"/>
                                    <input id="longitudine" type="hidden" name="longitudine" value="vuoto"/>
                                    <label class="editable">Telefono<br /><input name="telefono" value="<%=request.getAttribute("telefono").toString()%>"/></label><br />
                                </fieldset>
                                <fieldset><legend><em>Dati dell'account</em></legend>
                                    <label>Email<br /><input name="email" value="<%=request.getAttribute("email").toString()%>" disabled="disabled"/><br />
                                        <br />
                                        <label class="editable"><a href="MainController?q=edit_password">Cambia password</a></label><br /><br />

                                        <label class="editable">Immagine<br /><input name="urlimmagine" value="<%=request.getAttribute("urlimmagine").toString()%>"/></label>
                                        <br />
                                        <br /><p class="error">${error}</p><br />
                                        <input type="submit" value="REGISTRA"/>
                                </fieldset>
                            </form>
                            <br />
                        </div>
                        <%@ include file="/WEB-INF/common/footer.jsp"%>
                    </div>
                </div>
            </div>
        </div>
    </body>
</html>

